function pvalue_legend(alpha, logStart, logEnd, dirName)
% legend for p values in CellMaps.m
% 2006 ML

if exist(fullfile(dirName, 'legend_pvalue.jpg')) == 0
    red = [1, 0, 0];
    blue = [0, 0, 1];
    colorTable = MakeColorGradationTable(blue, red, 100);

    matrix = 100:-1:1;
    matrix = repmat(matrix, 5, 1);

    c = figure;
    set(c, 'PaperPosition', [0 0 8 .7], 'PaperSize', [8 .7], 'Position', [300 300 400 50]);
    h = image(matrix);
    tmp = round((10 .^ (-([90:-10:0] / 100) * (logEnd - logStart)) + logStart)*1000)/1000;
    set(gca, 'YTick', [], 'XTickLabel', tmp, 'FontSize', 14, 'Position', [0.001 0.28 0.999 0.9])
    axis image
    tmp = 100 - ((-log10(alpha)  - logStart)/ (logEnd - logStart) * 100);
    line([tmp tmp], [0 11], 'Color', 'black');
    colormap(colorTable);
    print('-djpeg', fullfile(dirName, 'legend_pvalue.jpg'));
end
